﻿package Interface 
{			
	import Interface.WelcomePageClasses.TextScroller;
	import Interface.WelcomePageClasses.ScrollingLabel;
	import Core.Page;
	
	import flash.events.MouseEvent;	
	import flash.display.MovieClip;				
	import flash.events.Event;

	public class StartMenu extends ArrowsMenu
	{			
		private var FText:TextScroller;
		private var FClicked:Boolean;
		
		public function StartMenu() 
		{
			FClicked = false;
			FText = getChildByName('Text') as TextScroller;
		}
		
		override protected function OnLeft(e:MouseEvent):void
		{
			FText.MoveLeft();
		}
		
		override protected function OnRight(e:MouseEvent):void
		{
			FText.MoveRight();
		}
		
		public function AddItem(APage:Page = null):void
		{
			with(FText.AddField(APage.MenuName))
			{
				PageLink = APage;
				addEventListener(MouseEvent.MOUSE_DOWN, OnTextClick);
			}
		}	
		
		private function OnTextClick(e:MouseEvent):void
		{
			if(!FClicked)
			{
				FClicked = true;
				removeEventListener(MouseEvent.MOUSE_DOWN, OnTextClick);
				PageWelcome(parent).Hide(ScrollingLabel(e.target.parent).PageLink);
			}
		}
	}	
}
